package com.todo.event.activity.application.handler.dynamicwords;

import com.todo.event.activity.common.enums.EventActivityDynamicWordEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * @author azhebuxing
 * @date 2025/1/13 17:11
 * @description 通用字段的获取处理 - 有条件情况则是从大数据计算能力中获取，数据可以扩展至 【最近到达城市】【上次登录时间】【当前登录地址】【最近一笔消费额度】等等
 */
@Slf4j
@Component
public class GeneralWordsHandle extends AbstractDynamicWordsHandle {

    public final static Set<String> GENERAL_WORDS = new HashSet<>();

    {
        GENERAL_WORDS.add(EventActivityDynamicWordEnum.CURRENT_CITY.getCode());
    }


    @Override
    protected boolean match(List<EventActivityDynamicWordEnum> dynamicWords) {
        for (EventActivityDynamicWordEnum dynamicWord : dynamicWords) {
            if (GENERAL_WORDS.contains(dynamicWord.getCode())) {
                return true;
            }
        }
        return false;
    }

    @Override
    protected Map<EventActivityDynamicWordEnum, Object> doHandle(List<EventActivityDynamicWordEnum> dynamicWords) {
        Map<EventActivityDynamicWordEnum, Object> result = new HashMap<>();
        result.put(EventActivityDynamicWordEnum.CURRENT_CITY, "北京");
        return result;
    }
}
